<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ page import="java.util.List" %>
<%@ page import="kokonut.shop.product.TShirtModel" %>
<%@ page import="persistence.PMF" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<jsp:useBean id="ProductPersistence" class="persistence.ProductPersistence" scope="request" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="/administration/adminStyle.css" rel="stylesheet" type="text/css"/>
        <title>Kokonut Web :: Admin</title>
    </head>
    <body>
        <div class="wrapper">
            <h1>Kokonut Web</h1>
            Shop Admin
            <br/>
            <br/>
            <a href="/admin/productEditor?action=saveProduct">Produktua sortu</a>
            <br/>
            Product List
            <br/>
            <%
                        List<TShirtModel> productList = ProductPersistence.loadModelList();
                        if (productList.isEmpty()) {
            %>
            <p>No products saved</p>
            <%    } else {%>
            <table>
                <tr>
                    <th>Ref</th>
                    <th>Name</th>
                    <th></th>
                    <th></th>
                </tr><%
                        for (TShirtModel p : productList) {
                %>
                <tr bgcolor="#F8F8F8 ">
                    <td bgcolor="#E8E8E8" ><%=p.getRef()%></td>
                    <td><%=p.getName()%></td>
                    <td class="edit"><a href="/admin/productEditor?action=editProduct&ref=<%=p.getRef()%>">edit</a></td>
                    <td class="delete"><a href="/productEraser?ref=<%=p.getRef()%>">delete</a></td>
                </tr>
                <%
                                }
                            }
                %>
            </table>
            <br/>
            <a href="/admin/dashboard">back</a>
        </div>
    </body>
</html>